package com.jxm.websocket.ws.utils;

import com.alibaba.fastjson2.JSON;
import com.jxm.websocket.ws.entity.ResultMessage;

/**
 * @Author: jxm
 * @Description: 封装消息工具类
 * @Date: 2023/7/4 10:11
 * @Version: 1.0
 */
public class MessageUtil {

    /**
     *
     * @param isSystem 是否是系统消息
     * @param fromName 来自谁
     * @param message 消息内容
     * @return
     */
    public static String getMessage(boolean isSystem,String fromName,Object message){
        ResultMessage msg = new ResultMessage();
        msg.setMessage(message);
        msg.setFromName(fromName==null?"":fromName);
        msg.setIsSystem(isSystem);
        String s = JSON.toJSONString(msg);
        return s;
    }

}
